import it.sauronsoftware.jave.*;
import org.junit.Test;

import java.io.File;

/**
 * Created by gx on 2017/4/14.
 */
public class Mytest {

    public static void main(String[] args) throws EncoderException {
        File source = new File("19206715_114648.mp4");
        File target = new File("target1.mp4");
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("h263");
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp4");
        attrs.setAudioAttributes(audio);
        Encoder encoder = new Encoder();
        encoder.encode(source,target,attrs);
    }

    @Test
    public void test1() throws Exception {
        File source = new File("19206715_114648.mp4");
        File target = new File("target1.mp4");
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("libmp3lame");
        audio.setBitRate(new Integer(56000));
        audio.setChannels(new Integer(1));
        audio.setSamplingRate(new Integer(22050));
        VideoAttributes video = new VideoAttributes();
        video.setCodec(VideoAttributes.DIRECT_STREAM_COPY);
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp4");
        attrs.setAudioAttributes(audio);
        attrs.setVideoAttributes(video);
        Encoder encoder = new Encoder();
        encoder.encode(source,target,attrs);
    }
    @Test
    public void test2() throws EncoderException {
        File source = new File("19206715_114648.mp4");
        File target = new File("target2.mp4");
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("libfaac");
        audio.setBitRate(128000);
        audio.setSamplingRate(44100);
        audio.setChannels(2);
        VideoAttributes video = new VideoAttributes();
        video.setCodec("h263");
        video.setBitRate(160000);
        video.setFrameRate(15);
        video.setSize(new VideoSize(176,144));
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("mp4");
        attrs.setAudioAttributes(audio);
        attrs.setVideoAttributes(video);
        Encoder encoder = new Encoder();
        encoder.encode(source,target,attrs);

    }
}
